<%@ Page debug="true" %>
<%@ Import Namespace="System.Diagnostics" %>


<html>

<script language="VB" runat="server">

  Sub Page_Load(Sender As Object, e as EventArgs)

    Dim ccdc As New CounterCreationDataCollection()
    Dim pc  As New PerformanceCounter
    dim cat as new PerformanceCounterCategory("Wrox")
    
    If PerformanceCounterCategory.Exists("Wrox") Then
      PerformanceCounterCategory.Delete("Wrox")
    End If
    ccdc.Add(New CounterCreationData("Counter1", "1", PerformanceCounterType.NumberOfItems32))
    ccdc.Add(New CounterCreationData("Counter2", "2", PerformanceCounterType.NumberOfItems32))
    ccdc.Add(New CounterCreationData("Counter3", "3", PerformanceCounterType.NumberOfItems32))
    ccdc.Add(New CounterCreationData("Counter4", "4", PerformanceCounterType.NumberOfItems32))
    PerformanceCounterCategory.Create("Wrox", "Wrox Press Professional ASP.NET Samples", ccdc)

    'Dim pc0 As New PerformanceCounter("Wrox", "Counter2", "2_0", False)
    'Dim pc1 As New PerformanceCounter("Wrox", "Counter2", "2_1", False)
    'Dim pcT As New PerformanceCounter("Wrox", "Counter2", "2_Total", False)
    Dim pcc0 As New PerformanceCounter("Wrox", "Counter3", "3_0", False)
    'Dim pcc1 As New PerformanceCounter("Wrox", "Counter4", False)
    
    
    dim idcc as InstanceDataCollectionCollection
    dim idc as InstanceDataCollection
    dim ind as InstanceData
    dim catname as string
    dim ins as string
    
    idcc = cat.ReadCategory() 
    for each idc in idcc.values
      Response.Write(idc.CounterName & "<br/>")
      for each ind in idc.values
        Response.Write("&nbsp;&nbsp;" & ind.InstanceName & "<br/>")
      Next
    Next

    For each ind in idcc.Item("Counter4").values
      Response.Write("foo:" & ind.InstanceName & "<br/>")
    Next
    PerformanceCounterCategory.Delete("Wrox")

  End Sub

  
</script>

</html>